package com.vay.de.dang.online.ui.my;

import android.os.Bundle;

import com.vay.de.dang.online.ui.WithBack1Activity;
import com.vay.de.dang.online.ui.bill.BillAdapter;
import com.vay.de.dang.online.ui.HomeActivity;

import com.vay.de.dang.online.R;
import com.vay.de.dang.online.databinding.ActivityBillListBinding;

public class OrderListActivity extends WithBack1Activity {

    private int fromType = 0;
    private ActivityBillListBinding binding;
    private BillAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityBillListBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        if (getIntent() != null) {
            fromType = getIntent().getIntExtra("fromType", -1);
            if (fromType == 0) {
                binding.titleTv.setText(R.string.title_bill_all);
            } else if (fromType == 1) {
                binding.titleTv.setText(R.string.title_bill_pending);
            } else if (fromType == 2) {
                binding.titleTv.setText(R.string.title_bill_repayment);
            }
        }

        binding.bntBackHome.setOnClickListener(view -> finish());
        mAdapter = new BillAdapter(mActivity);
        mAdapter.setBillType(fromType);
        binding.pullView.setRecyclerAdapter(mAdapter);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mAdapter.onResume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        HomeActivity.reloadHome();
    }
}
